//
//  SubscribeStoreRequest.m
//  BaseProject
//
//  Created by 王洋 on 2021/3/25.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "SubscribeStoreRequest.h"

@implementation SubscribeStoreRequest

+ (void)request_subscribeStoreWithModel:(SubscribeModel *)model AndSeller:(NSString *)sellerId comption:(void (^)(BOOL success))comption{

    NSMutableDictionary *dic = @{}.mutableCopy;
    dic = [model modelToJSONObject];
    [dic setValue:sellerId forKey:@"cdSellerId"];
    [dic setValue:[TTUserModel sharedObject].userId forKey:@"cdUserId"];
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,API_subscribeStore];
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        if ([data isKindOfClass:[NSDictionary class]]) {
            //请求成功
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            if (code == 10000) {
                [SVProgressHUD showSuccessWithStatus:[data valueForKey:@"message"]];
                [SVProgressHUD dismissWithDelay:1];
                comption(YES);
            } else {
                [SVProgressHUD showErrorWithStatus:[data valueForKey:@"message"]];
                [SVProgressHUD dismissWithDelay:1];
                comption(NO);
            }
        }
    } FailedBlock:^(NSError * _Nonnull error) {
        comption(NO);
    }];
}

@end
